package com.booza.dao;

import java.util.Collection;
import java.util.List;

import com.booza.model.Friend;

/**
 * The DAO interface to manage friends.
 */
public interface FriendDAO
{
	/**
	 * Fetches all friends entry in table.
	 * 
	 * @return all friends
	 */
	List<Friend> fetchAll();

	/**
	 * Fetches friends for the given user represented by the <code>accountId</code> parameter.
	 * 
	 * @param accountId
	 *          - id representing the user
	 * @return matching friend details
	 */
	List<Friend> findFriendsForAccount(Integer accountId);

	/**
	 * Adds friends to the friends table.
	 * 
	 * @param friends
	 *          - list of rows to be inserted
	 */
	void createFriendsForAccount(List<Friend> friends);

	/**
	 * Updates friend status to accepted/rejected based on user action.
	 * 
	 * @param friends
	 */
	void updateFriendsForAccount(Friend friends);

	/**
	 * Finds the total number of friends for the user.
	 * 
	 * @param accountId
	 *          - id representing the user
	 * @return count of friends
	 */
	long findFriendsCount(Integer accountId);

	/**
	 * Finds the friends that the user has.
	 * 
	 * @param accountId
	 *          - id of the user to search for
	 * @return list of all friends for the user
	 */
	Collection<Friend> searchFriends(Integer accountId);

	/**
	 * Checks if the user represented by account id and the user represented by <code>friendId</code> are already friends.
	 * 
	 * @param accountId
	 *          -id the user1
	 * @param friendId
	 *          - id the user2
	 * @return Return true if they are friends, false if they are not.
	 */
	boolean areFriends(Integer accountId, Integer friendId);

	/**
	 * Finds list of pending friend requests.
	 * 
	 * @param accountId
	 */
	Collection<Friend> findFriendRequests(Integer accountId);

	/**
	 * Find the row from friends table for the given <code>accountId</code> and <code>friendId</code>.
	 * 
	 * @param accountId
	 * @param friendId
	 */
	Friend findFriend(Integer accountId, Integer friendId);

	/**
	 * Finds the matching row, if the <code>accountId</code> has rejected <code>accountId</code>.
	 * 
	 * @param accountId
	 * @param friendId
	 */
	Friend findRejectRequest(Integer accountId, Integer friendId);	
	
	
	/**
	 * @param friendId
	 * @return Return the amount of friends deleted.
	 */
	void removeFriend(Integer friendId);
}
